// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   LoginAction.java

package com.boci.clientapp.authentication.action;

import com.boci.clientapp.authentication.LoginPanel;
import com.boci.clientapp.authentication.handler.LoginHandler;
import com.boci.clientapp.authentication.vo.LoginVO;
import com.boci.clientapp.main.*;
import com.boci.common.action.AbstractAction;
import com.boci.common.constant.RequestTypeConst;
import com.boci.common.handler.StaticConnectionParam;
import com.boci.common.util.*;
import java.io.IOException;
import java.net.ConnectException;
import java.util.HashMap;
import java.util.logging.Logger;

public class LoginAction extends AbstractAction
{

    public LoginAction()
    {
    }

    private void addExtraValues(HashMap pInpMap)
    {
        pInpMap.put("Submit", "Submit");
        pInpMap.put("channel", "TRADEXPRESS");
        pInpMap.put("version", ClientAppLoader.getAppConfigurator().getAppConfig("VERSION"));
    }

    public void doProcess(HashMap pInpMap, String pActionType)
    {
    	try{
	        appServ.setBusy(true);
	        if(pActionType.equals("LOGIN_ACTION"))
	        {
	            String strReqType = RequestTypeConst.BOCI_LOGIN_URL;
	            String strUserID = (String)pInpMap.get("login");
	            String strPasswd = (String)pInpMap.get("password");
	            addExtraValues(pInpMap);
	            LoginHandler loginHandler = new LoginHandler(strReqType);
	            LoginVO loginVO = (LoginVO)loginHandler.login(pInpMap);
	            appServ.login(strUserID, strPasswd, loginVO);
	            appServ.getMainPanel().showLoginPanel(false);
	            StaticConnectionParam.getInstance().setStrEncPass(loginHandler.getEncPasswd());
	        } else
	        if(pActionType.equals("CONTACTUS_ACTION"))
	            appServ.showContactUsDialog(true);
	        else
	        if(pActionType.equals("PROXY_ACTION"))
	            appServ.showProxyDialog(true);
	        else
	            appServ.getMainPanel().getLoginPanel().refresh();
    	}catch(AppException appEx){
    		logger.info(StringUtil.formatException(appEx));
            if(appEx.getReturnCode().equals("4"))
            {
                appServ.showWarningDialog(null, appEx.getMessage());
                String strUserID = (String)pInpMap.get("login");
                appServ.showChgPassDialog(strUserID, true);
            } else
            if(!appEx.getReturnCode().equals("6") && !appEx.getReturnCode().equals("0"))
                appServ.showErrorDialog(null, appEx.getMessage());
    	}catch(ConnectException conEx){
            logger.severe(StringUtil.formatException(conEx));
            appServ.showNetworkErrDialog();
    	}catch(IOException IOEx){
            logger.severe(StringUtil.formatException(IOEx));
            appServ.showNetworkErrDialog();
    	}catch(Exception sysEx){
    		logger.severe(StringUtil.formatException(sysEx));
            appServ.showSysErrDialog();
    	}finally{
    		appServ.setBusy(false);
    	}
    	return;
    }
}
